#include "StdAfx.h"
#include "ColorValue.h"

const ColorValue ColorValue::Black = ColorValue(0, 0, 0);
const ColorValue ColorValue::White = ColorValue(1, 1, 1);
ColorValue::ColorValue(void)
{
    m_b = m_g = m_r = 0;
}


ColorValue::~ColorValue(void)
{
}

ColorValue& ColorValue::operator+=( ColorValue& color )
{
    this->m_r += color.R();
    this->m_g += color.G();
    this->m_b += color.B();

    return *this;	
}

ColorValue& ColorValue::operator*=( ColorValue& color )
{
    this->m_r *= color.R();
    this->m_g *= color.G();
    this->m_b *= color.B();
    return *this;
}

ColorValue& ColorValue::operator*=( float rate )
{
    this->m_r *= rate;
    this->m_g *= rate;
    this->m_b *= rate;
    return *this;	
}

ColorValue operator+( ColorValue& color1, ColorValue& color2 )
{
	return ColorValue(color1.R() + color2.R(), color1.G() + color2.G(), color1.B() + color2.B());
}

ColorValue operator*( ColorValue& color1, ColorValue& color2 )
{
	ColorValue temp = color1;
    temp.m_r *= color2.m_r;
    temp.m_g *= color2.m_g;
    temp.m_b *= color2.m_b;
    return temp;
}

ColorValue operator*( float rate, ColorValue& color2 )
{
    color2.m_r *= rate;
    color2.m_g *= rate;
    color2.m_b *= rate;
    return color2;
}

ColorValue operator*( ColorValue& color1, float rate )
{
    color1.m_r *= rate;
    color1.m_g *= rate;
    color1.m_b *= rate;
    return color1;
}
